<!--  -->
<template>
  <div id="container">
     <HeaderQ></HeaderQ>
    <Navigation></Navigation>
    <div id="wrapList01" class="clearfix" v-cloak>
    <div class="wraplist01 clearfix mt60 myQuestion">
        <div class="fl list-left">
            <div class="pmc-div">
                <div class="form-p mb20">
                    <label class="f-l fl"><span class="red">*</span>标题：</label>
                    <div class="f-r posr">
                        <input type="text" name="title" id="title" maxlength="64" class="input-text" placeholder="一句话描述你的疑问，64字以内" v-model="title" />
                    </div>
                </div>
                <div class="form-p mb20">
                    <label class="f-l fl"><span class="red">*</span>所属分类：</label>
                    <div class="f-r posr">

                        <select class="input-text select-input" id="cid" v-model="selected">
                            <option v-for="cate in cates" v-bind:value="cate.CategoryId" :key="cate.id">
                                {{ cate.Title }}
                            </option>
                        </select>
                    </div>
                </div>
                <div class="form-p mb20">
                    <label class="f-l fl">问题标签：</label>
                    <div class="f-r posr">
                        <input type="text" name="tags" id="tags" placeholder="" class="input-text" value="" />
                        <label><span style="color:red">每个标签超过16字的部分将被舍弃，请控制字数</span></label>
                    </div>                
                </div>
                <div class="form-p mb20">
                    <label class="f-l fl"><span class="red">*</span>问题描述：</label>
                    <div class="f-r posr">
                       <ueditor></ueditor>
                    </div>
                </div>
            </div>
            <div class="tc mt20 mr15">
                <button class="btn btn-submit" id="submit" v-on:click="submit">提交</button>
                <button class="btn btn-clear" v-on:click="closeWindow();">取消</button>
            </div>
        </div>
        <div v-if="from!='pmc'" class="fr list-right question-right">
            <h3 class="h3-top">相似问题</h3>
            <div class="clear mt10 mb10" v-for="item in similar" :key="item.id" >
                <a class="h3 ellipsis question" v-bind:href="path+'home/QuestionDetail?qid='+item.QuestionId" target="_blank">{{item.Title}}</a>
                <p class="clearfix date">
                    <span class="fl">{{item.CreateTime}}</span>
                    <span class="fr">{{item.AnswerNum}}回复({{item.CreatTimeTimeShow}})</span>
                </p>
            </div>
        </div>
    </div>
</div>
  </div>
</template>

<script>
import Navigation from "./navigation";
import HeaderQ from "../faq/components/header"
// import tinymce from './tinymceedit.vue'
import ueditor from'./ueditor.vue'
export default {
  name:'',
  components: {
      Navigation,HeaderQ,ueditor
  },
  props:{},
  data () {
  return {
                path: ('@Url.Content("~")').replace(/\/\/$/, '\/'),
                title: '',
                tag: '',
                detail: '',
                cates: "",
                similar: [],
                selected: '@ViewBag.cid',
                from:'@ViewBag.from',
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted(){},
  methods: {
                submit: function () {
                    var title = $("#title").val().trim();
                    var content = ue.getContent();
                    var tags = $("#tags").val().trim();
                    var cid = $("#cid").val();
                    if (title.length === 0) {
                        alert('请填写标题');
                        return;
                    }
                    if (content.length===0) {
                        alert('请填写描述');
                        return;
                    }
                    if (cid == null) {
                        alert('请选择所属分类');
                        return;
                    }
                    $('#submit').attr("disabled", true);

                    $.post("Url.Content(~/home/addquestion)", { "title": htmlEncode(title), "content": htmlEncode(content), "cid": $("#cid").val(), tags: htmlEncode(tags) }, function(data) {
                        $('#submit').attr("disabled", false);
                        if (data.data !== "") {
                            $.post("@Url.Content~/home/sendQMessage", { "qid": data.data, "type": 1 });
                            alert(data.msg);
                            if ((localSearch == "?from=pmc")) {
                                window.parent.CancelIframe();
                            } else {
                                window.location.href = "@Url.Content(~/home/questiondetail?qid="+data.data;
                            }
                        } else {
                            alert(data.msg);
                        }
                    });
                },
                closeWindow: function () {
                    if ((localSearch == "?from=pmc")) {
                        window.parent.CancelIframe();
                    } else {
                        window.close();
                    }
                }
            }
}

</script>
<style lang='less' scoped>
</style>